terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 3.0"
    }
  }
  backend "s3" {
    bucket = "bradley-chatha"
    key    = "backup/aws_terraform_backup"
    region = "eu-west-2"
  }
}

provider "aws" {
  region = "eu-west-2"
}

module "networking" {
  source = "./modules/networking"
}

module "iam" {
  source = "./modules/iam"
}

module "db" {
  source                = "./modules/db"
  rds_security_group_id = module.networking.rds_security_group_id
  rds_subnet_ids        = [module.networking.private_1_subnet_id, module.networking.private_2_subnet_id]
}

module "public_1" {
  source               = "./infra/provision/public_1"
  network_interface_id = module.networking.public_1_network_interface_id
  iam_instance_profile = module.iam.ssm_profile
}

module "private_1" {
  source               = "./infra/provision/private_1"
  network_interface_id = module.networking.private_1_network_interface_id
  iam_instance_profile = module.iam.ssm_profile
}

module "private_2" {
  source               = "./infra/provision/private_2"
  network_interface_id = module.networking.private_2_network_interface_id
  iam_instance_profile = module.iam.ssm_profile
}

module "cloudwatch" {
  source = "./infra/provision/cloudwatch"
}